<script>
	import request from '@/utils/api.js'
	export default {
		
		
		onLaunch:function(){
			uni.getStorage({
				key: 'token',
				success: function(res) {
					if (res.data !== "") {
						request('/valid').then(resp => {
							console.log('resp', resp);
							if (resp.msg === 'ok') {
								uni.reLaunch({
									url: '/pages/code/code'
								})
							} else {
								console.log('token过期');
								uni.removeStorage({
									key: 'token'
								})
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}
						})
					} else {
						uni.reLaunch({
							url: '/pages/login/login'
						})
					}
				},
				fail() {
					console.log('未登录');
					// 未登录，跳转登录
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
			})
		},
		onShow: function() {
			console.log('app show');
			
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
